package com.kee.common.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegxUtil {
	
	/**
	 * UBB标签解析器
	 * @param txt
	 * @param ubb
	 * @return
	 */
	public static String UBBParser(String txt,String ubb){
		String reg = "\\[" + ubb + "](.*)\\[/" + ubb + "]";
		Pattern pattern = Pattern.compile(reg);
		Matcher m = pattern.matcher(txt);
		String content = null;
		while (m.find()) {
			content = m.group(1);
			break;
		}
		return content;
	}
	
	/**
	 * 注释清楚
	 * <!-- xxx -->去除
	 * @param txt
	 * @return
	 */
	public static String NoteEscapeParser(String txt){
		if (txt != null) {
			String regex = "<!--(.*?)-->";
			return txt.replaceAll(regex, "");
		} else {
			return "";
		}
	}
	
	
	public static void main(String[] args) {
		String g = NoteEscapeParser("解：“正”和“负”相对，所以如果+80元表示收入80元，那么支出20元表示为-20元．故选：B．");
		System.out.println(g);
	}
}
